<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<script type="text/javascript">
	function login_register() {
		window.location.href = "index.do?mod=register";
	}
	
	$(function(){
		function login_success(data) {
			if(data.state == 'success'){
				window.location = 'index.do';
			}else if(data.state == 'login_username_empty'){
				alert('用户名为空');
			}else if(data.state == 'login_password_empty'){
				alert('密码为空');
			}else if(data.state == 'login_user_not_exist'){
				alert('用户不存在');
			}else if(data.state == 'login_password_wrong'){
				alert('密码错误');
			}else{
				alert(data.state);
			}
		}

		$('#login_form').ajaxForm({
			success : login_success
		});
	});
</script>
<div class='login'>
	<div class='left'>
		<a href="index.do"><img src="${pageContext.request.contextPath}/css/images/logo.png" class="logo" /></a>
	</div>
	<c:if test="${empty user}">
		<div id='login_div' class='login_div right'>
			<form id='login_form' action="login.do" method="post">
				<table>
					<tr>
						<td><a href="javascript:;">用户名</a></td>
						<td><input id="login_username" name="login_username" tabindex="1"/></td>
						<td><input id="login_autologin" name="login_autologin"
							type="checkbox" tabindex="3"/></td>
						<td><a href="javascript:;" >自动登录</a></td>
						<td><a href="javascript:;" tabindex="5">找回密码</a></td>
					</tr>
					<tr>
						<td><a href="javascript:;">密码</a></td>
						<td><input id="login_password" name="login_password"
							type="password" tabindex="2"/></td>
						<td colspan='2'><button class='login_button' tabindex="4">登录</button></td>
						<td><a href="javascript:;" onclick="login_register();" tabindex="6">立即注册</a></td>
					</tr>
				</table>
			</form>
		</div>
	</c:if>
	<c:if test="${!empty user}">
		<div class='avt right'>
			<img src='login/loggedin_avatar.do'/>
		</div>
		<div id='loggedin_div' class='login_div right'>
			<table>
				<tr>
					<td>
						<a href="javascript:;" title="访问我的空间">${user.name}</a>
						<span class="pipe">|</span>
						<a href="javascript:;">设置</a>
						<span class="pipe">|</span>
						<a href="javascript:;">消息</a>
						<span class="pipe">|</span>
						<a href="javascript:;">提醒</a>
						<span class="pipe">|</span>
						<a href="javascript:;">退出</a>
					</td>
				</tr>
				<tr>
					<td>
						<a href="javascript:;">积分</a>
						<span class="pipe">|</span>
						<a href="javascript:;">用户组: 新手上路</a>
					</td>
				</tr>
			</table>
		</div>
	</c:if>
</div>